package com.wangyk.user.controller;

import com.netflix.discovery.converters.Auto;
import com.wangyk.rabbitmqcommon.VO.ResultVO;
import com.wangyk.rabbitmqcommon.model.user.Product;
import com.wangyk.user.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/product")
@Slf4j
public class ProductController
{
    @Autowired
    private ProductService productService;

    @RequestMapping("/save_product.do")
    @ResponseBody
    public ResultVO saveProduct(@RequestBody Product product)
    {
        ResultVO resultVO = productService.saveProduct(product);
        return resultVO;
    }

    @RequestMapping("/delete_num.do")
    @ResponseBody
    public ResultVO deleteNum(Integer productId)
    {
        log.info("No Sync controller:"+System.currentTimeMillis());
        ResultVO resultVO = productService.deleteNum(productId);
        return resultVO;
    }

    @RequestMapping("/delete_num_sync.do")
    @ResponseBody
    public ResultVO deleteNumSync(Integer productId)
    {
        log.info("Sync controller:"+System.currentTimeMillis());
        ResultVO resultVO = productService.deleteNumSync(productId);
        return resultVO;
    }

    @RequestMapping("/delete_num_lock.do")
    @ResponseBody
    public ResultVO deleteNumLock(Integer productId)
    {
        log.info("Sync controller:"+System.currentTimeMillis());
        ResultVO resultVO = productService.deleteNumLock(productId);
        return resultVO;
    }
}
